package com.sc.nft.admin.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sc.nft.admin.request.CopyrightNamePageRequest;
import com.sc.nft.admin.request.IdRequest;
import com.sc.nft.admin.request.NamePageRequest;
import com.sc.nft.admin.request.NameRequest;
import com.sc.nft.annotation.SysMemberLogin;
import com.sc.nft.entity.dto.*;
import com.sc.nft.entity.vo.*;
import com.sc.nft.entity.vo.mall.MallPaymentMethodVO;
import com.sc.nft.service.CopyrightAuctionRecordService;
import com.sc.nft.service.CopyrightAuctionRoundService;
import com.sc.nft.service.CopyrightAuctionService;
import com.sc.nft.service.CopyrightAuctionUserBiddingService;
import com.sc.nft.sup.PageResult;
import com.sc.nft.sup.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;


@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/admin/copyrightAuction")
@Api(tags = "版权商品竞拍模块")
public class CopyrightAuctionController {


    private final CopyrightAuctionService copyrightAuctionService;

    private final CopyrightAuctionUserBiddingService copyrightAuctionUserBiddingService;

    private final CopyrightAuctionRoundService copyrightAuctionRoundService;

    private final CopyrightAuctionRecordService copyrightAuctionRecordService;


    @ApiOperation(value = "版权藏品拍卖里列表接口", notes = "版权藏品拍卖里列表接口", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/collection/page", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public PageResult<CopyrightAuctionAdminPageVO> collectionPage(@RequestBody CopyrightNamePageRequest nameRequest) {
        return PageResult.success(copyrightAuctionService.collectionPage(nameRequest.getName(),nameRequest.toMp()));
    }


    @ApiOperation(value = "版权藏品拍卖添加接口", notes = "版权藏品拍卖添加接口", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/collection/add", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result collectionAdd(@Valid @RequestBody CopyrightAuctionAdminDTO copyrightAuctionAdminDTO) {
        copyrightAuctionService.collectionAdd(copyrightAuctionAdminDTO);
        return PageResult.success();
    }


    @ApiOperation(value = "拍卖配置修改", notes = "拍卖配置修改", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/config/save", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result configSave(@Valid @RequestBody CopyrightAuctionConfigAdminDTO configAdminDTO) {
        copyrightAuctionService.configSave(configAdminDTO);
        return Result.success();
    }

    @ApiOperation(value = "拍卖配置详情", notes = "拍卖配置详情", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/config/detail", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result<CopyrightAuctionConfigAdminVO> configDetail() {
        return Result.success(copyrightAuctionService.configDetail());
    }


    @ApiOperation(value = "版权藏品拍卖按钮", notes = "版权藏品拍卖按钮", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/collection/updateStatus", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result collectionUpdateStatus(@Valid @RequestBody CopyrightAuctionUpdateStatusAdminDTO copyrightAuctionAdminDTO) {
        copyrightAuctionService.collectionUpdateStatus(copyrightAuctionAdminDTO);
        return PageResult.success();
    }

    @ApiOperation(value = "拍卖汇总记录", notes = "拍卖汇总记录", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/auctionUserBidding/data", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result<CopyrightAuctionUserBiddingAdminDataVO> copyrightAuctionRecordAdminData(@Valid @RequestBody CopyrightAuctionUserBiddingAdminDataDTO copyrightAuctionAdminDTO) {
        return Result.success(copyrightAuctionUserBiddingService.copyrightAuctionRecordAdminData(copyrightAuctionAdminDTO));
    }

    @ApiOperation(value = "出价用户列表", notes = "出价用户列表", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/auctionUserBidding/List", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public PageResult<CopyrightAuctionUserBiddingAdminListVO> copyrightAuctionUserBiddingAdminList(@Valid @RequestBody CopyrightAuctionUserBiddingAdminListDTO copyrightAuctionUserBiddingAdminListDTO) {
        return PageResult.success(copyrightAuctionUserBiddingService.copyrightAuctionUserBiddingAdminList(copyrightAuctionUserBiddingAdminListDTO));
    }

    @ApiOperation(value = "后台 拍卖轮数", notes = "后台 拍卖轮数", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/round/List", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result<List<CopyrightAuctionRoundAdminVO>> copyrightAuctionRoundAdminList(@Valid @RequestBody CopyrightAuctionRoundAdminDTO copyrightAuctionUserBiddingAdminListDTO) {
        return Result.success(copyrightAuctionRoundService.copyrightAuctionRoundAdminList(copyrightAuctionUserBiddingAdminListDTO));
    }

    @ApiOperation(value = "后台拍卖记录", notes = "后台拍卖记录", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/record/List", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public PageResult<CopyrightAuctionRecordAdminListVO> copyrightAuctionRecordAdminUserList(@Valid @RequestBody CopyrightAuctionRecordAdminListDTO copyrightAuctionRecordAdminListDTO) {
        return PageResult.success(copyrightAuctionRecordService.copyrightAuctionRecordAdminUserList(copyrightAuctionRecordAdminListDTO));
    }

}
